package com.github.bridge.controller;


import com.github.bridge.annotation.SysLog;
import com.github.bridge.handler.BridgeHandler;
import com.github.bridge.request.InnerSignatureDTO;
import com.github.bridge.request.OuterUserCreateAndSignatureDTO;
import com.github.bridge.request.OuterUserSignatureDTO;
import com.github.bridge.request.SignDetailDTO;
import com.github.bridge.response.InnerSignatureVO;
import com.github.bridge.response.OuterOrgSignatureVO;
import com.github.bridge.response.OuterUserSignatureVO;
import com.github.bridge.response.SignDetailVO;
import com.github.bridge.util.R;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/signature")
@RequiredArgsConstructor
@Tag(name = "签署相关")
@ApiSupport(order = 4, author = "张辉")
public class SignatureController {
    private final BridgeHandler bridgeHandler;

    @PostMapping("/outerUserSignature")
    @Operation(summary = "外部用户签章")
    @SysLog(value = "外部用户签章")
//    @Log(value = "外部用户签章", position = Position.ENABLED, readWriteType = ReadWriteType.WRITE)
    public R<OuterUserSignatureVO> outerUserSignature(@RequestBody @Validated OuterUserSignatureDTO dto)  {
        OuterUserSignatureVO vo = bridgeHandler.outerUserSignature(dto);
        return R.ok(vo);
    }

    @PostMapping("/outerUserCreateAndSignature")
    @Operation(summary = "外部用户创建并签章")
    @SysLog(value = "外部用户创建并签章")
//    @Log(value = "外部用户创建并签章", position = Position.ENABLED, readWriteType = ReadWriteType.WRITE)
    public R<OuterUserSignatureVO> outerUserCreateAndSignature(@RequestBody @Validated OuterUserCreateAndSignatureDTO dto)  {
        OuterUserSignatureVO vo = bridgeHandler.outerUserCreateAndSignature(dto);
        return R.ok(vo);
    }

    @PostMapping("/outerOrgSignature")
    @Operation(summary = "外部企业经办人签章")
    @SysLog(value = "外部企业经办人签章")
//    @Log(value = "外部企业经办人签章", position = Position.ENABLED, readWriteType = ReadWriteType.WRITE)
    public R<OuterOrgSignatureVO> outerOrgSignature(@RequestBody @Validated OuterUserSignatureDTO dto)  {
        OuterOrgSignatureVO vo = bridgeHandler.outerOrgSignature(dto);
        return R.ok(vo);
    }



    @PostMapping("/innerSignature")
    @Operation(summary = "内部签章")
    @SysLog(value = "内部签章")
//    @Log(value = "内部签章", position = Position.ENABLED, readWriteType = ReadWriteType.WRITE)
    public R<InnerSignatureVO> innerSignature(@RequestBody @Validated InnerSignatureDTO dto)  {
        InnerSignatureVO vo = bridgeHandler.innerSignature(dto);
        return R.ok(vo);
    }

    @PostMapping("/signDetail")
    @Operation(summary = "签署详情")
//    @Log(value = "签署详情", position = Position.ENABLED, readWriteType = ReadWriteType.WRITE)
    public R<SignDetailVO> signDetail(@RequestBody @Validated SignDetailDTO dto)  {
        SignDetailVO vo = bridgeHandler.signDetail(dto);
        return R.ok(vo);
    }


}
